<?php

class Application_Model_DbTable_Employes extends Zend_Db_Table_Abstract
{

    protected $_name = 'employes';

	public function getEmploye($id)
    	{
        $id = (int)$id;
        $row = $this->fetchRow('id = ' . $id);
        if (!$row) {
            throw new Exception("Impossible de trouver l'incident $id");
        }
        return $row->toArray();
    }
    
    
	public function addEmploye($civilite,$nom,$prenom,$fonction,$telephone,$email,$situation)
	{
		$data = array(
			
        	'civilite'=> $civilite,
        	'nom' => $nom,
        	'prenom'=>$prenom,
        	'fonction' => $fonction,
        	'telephone' => $telephone, 
        	'email' => $email,
			'situation' => $situation	
			

		);
		$this->insert($data);
	}
	
	public function updateEmploye($id,$civilite,$nom,$prenom,$fonction,$telephone,$email,$situation)
	{
		$data = array(
            'civilite'=> $civilite,
        	'nom' => $nom,
        	'prenom'=>$prenom,
        	'fonction' => $fonction,
        	'telephone' => $telephone, 
        	'email' => $email,
			'situation' => $situation
		);
		$this->update($data, 'id = '. (int)$id);
	}
	
public  function listCurrentEmploye(){
		$select = $this->select()->setIntegrityCheck(false)
		
		->from(array ('e' => 'employes'))
		->where ('e.situation != ?','unemployed');
		
		//echo $select;
			
		$r= $this->fetchAll($select);


		return $r;
	}
}

